package com.yonyou.iuap.pub;

import java.io.File;
import java.io.InputStream;

import org.springframework.util.StringUtils;


/**
 * @author Josh Wang(Sheng)
 *
 * @email  josh_wang23@hotmail.com
 */
public class FastDFSFile implements FileManagerConfig {

  private static final long serialVersionUID = -996760121932438618L;

  private String name;
  
  private File file;
  
  private String ext;
  
  private String height = "";
  
  private String width = "";
  
  private String author = FILE_DEFAULT_AUTHOR;
  
  private byte[] bytes;
  
  private InputStream input;
  
  public FastDFSFile(File file, String ext, String height,String width, String author) {
    super();
    this.name = file==null?"":file.getName();
    if(StringUtils.isEmpty(ext) && !StringUtils.isEmpty(this.name)){
    	this.ext = this.name.substring(this.name.lastIndexOf(".")+1,this.name.length());
    }else{
    	this.ext = ext;
    }
    this.file = file;
    this.height = height;
    this.width = width;
    this.author = author==null?FILE_DEFAULT_AUTHOR:author;
  }
  public FastDFSFile(byte[] bytes,String filename, String ext, String height,
	      String width, String author) {
	    super();
	    this.name = filename;
	    if(StringUtils.isEmpty(ext) && !StringUtils.isEmpty(this.name)){
	    	this.ext = this.name.substring(this.name.lastIndexOf(".")+1,this.name.length());
	    }else{
	    	this.ext = ext;
	    }
	    this.bytes = bytes;
	    this.height = height;
	    this.width = width;
	    this.author = author==null?FILE_DEFAULT_AUTHOR:author;
	  }
  public FastDFSFile(InputStream input,String filename, String ext, String height,
	      String width, String author) {
	    super();
	    this.name = filename;
	    if(StringUtils.isEmpty(ext) && !StringUtils.isEmpty(this.name)){
	    	this.ext = this.name.substring(this.name.lastIndexOf(".")+1,this.name.length());
	    }else{
	    	this.ext = ext;
	    }
	    this.input = input;
	    this.height = height;
	    this.width = width;
	    this.author = author==null?FILE_DEFAULT_AUTHOR:author;
	  }
  public String getExt() {
    return ext;
  }

  public void setExt(String ext) {
    this.ext = ext;
  }

  public String getHeight() {
    return height;
  }

  public void setHeight(String height) {
    this.height = height;
  }

  public String getWidth() {
    return width;
  }

  public void setWidth(String width) {
    this.width = width;
  }

  public String getAuthor() {
    return author;
  }

  public void setAuthor(String author) {
    this.author = author;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public File getFile() {
	  return file;
  }

  public void setFile(File file) {
	  this.file = file;
  }


  public byte[] getBytes() {
	  return bytes;
  }


  public void setBytes(byte[] bytes) {
	  this.bytes = bytes;
  }
public InputStream getInput() {
	return input;
}
public void setInput(InputStream input) {
	this.input = input;
}

}